<template>
  <div class="welcome">
    <van-nav-bar placeholder :border="false" />
    <div class="title">
      欢迎使用中恩科技智能办公平台
    </div>
    <div class="info">
      轻松办公 一切从简
    </div>
    <image class="img" src="https://oa.zeweb.org.cn/api/admin/sys-file/zeoa/8be1f57396394511ac320d479c3b7739.png" mode="aspectFill" alt="" />
    <button class="btn" type="primary" open-type="getPhoneNumber" @getphonenumber="onWxLogin">
      手机号一键登录
    </button>
  </div>
</template>

<script>
import { getAccessToken } from '@/utils/storage'
import { redirectToHome } from '@/utils/common'

export default {
  data() {
    return {
      from: '',
    }
  },
  beforeCreate() {
    // 根据 token 和 userType 决定第一页
    if (getAccessToken()) {
      redirectToHome()
    }
  },
  onLoad({ from }) {
    this.from = from
  },
  methods: {
    onWxLogin(res) {
      this.$store.dispatch('Login', res.detail.code)
    },
  },
}
</script>

<style lang="scss" scoped>
.welcome {
  margin-top: 50px;
  padding: 0 30px;

  .title {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 15px;
  }
  .info {
    font-size: 14px;
  }
  .img {
    display: block;
    margin: 80px auto 0;
    width: 221px;
    height: 234px;
  }
  .btn {
    margin-top: 60px;
    width: 280px;
    height: 36px;
    border-radius: 19px;
    font-size: 16px;
    line-height: 36px;
  }
}
</style>
